package com.zxl.thread.pool.runable;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

public class TestCachedThreadPool {

	public static void main(String[] args) {
//		ExecutorService executorService  = Executors.newCachedThreadPool();//有任务时创建线程，空闲线程保持60s
		ExecutorService executorService  = Executors.newFixedThreadPool(5);//固定线程数目的线程池，空闲线程一直保存
//		ExecutorService executorService  = Executors.newSingleThreadExecutor();//只有一个工作线程，依次执行任务
		
		for (int i = 0; i < 5; i++) {
			executorService.execute(new TestRunnable());
			System.out.println("------a"+i);
		}
		executorService.shutdown();
		
	}
}
